<?php
/**
 * Created by PhpStorm.
 * User: martinby
 * Date: 2018/3/5
 * Time: 23:25
 */
//layui的上传类
namespace app\admin\controller;
use think\Controller;
use think\Request;
 
class Upload extends Controller{
 
 

    public function upimg(){
        // 获取表单上传文件return Request::param('name');
         $files = request()->file('file');
        // 移动到框架应用根目录/uploads/ 目录下
        $path=ROOT_PATH . 'public' . DS . 'uploads'.DS.'examimg';
        
        $info = $files->move($path);
        if($info){
        // 成功上传后 获取上传信息
        // 输出 jpg
        //$a= $info->getExtension();
        // 输出 42a79759f284b767dfcb2a0197904287.jpg
            $domain= request()->domain();
        $imgp=$domain.'/sikuexam/public/uploads/examimg/'.$info->getSaveName();
            //$imgp='__ROOT__/public/uploads/examimg/'.$info->getSaveName();
        $data['src']=$imgp;$data['title']='';
            return myjson('0','success',count($files),$data);
        }else{
        // 上传失败获取错误信息s
        //echo $file->getError();
            return myjson('1','error',1,$data);
        }
        
    }










    

 
 
}